
/**
 * 获取字符串字节数
 */
String.prototype.getBytesLength = function() {
	var length = 0;
	for(i = 0; i < this.length; i++) {
		iCode = this.charCodeAt(i);
		if ((iCode >= 0 && iCode <= 255) || (iCode >= 0xff61 && iCode <= 0xff9f)) {
			length += 1;
		} else {
			length += 2;
		}
	}
	
	return length;
};

/**
 * 验证字符是否日期格式
 */
String.prototype.isDate = function() {
	var vl = this;
	var r = $.trim(vl).match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
	if (r == null) return false;
	var d = new Date(r[1], r[3]-1, r[4]);
	
	return (d.getFullYear() == r[1] && (d.getMonth()+1) == r[3] && d.getDate()==r[4]);
};
